package com.example.pets.model.entities.dao;



import androidx.room.Dao;
import androidx.room.Insert;
import androidx.room.OnConflictStrategy;
import androidx.room.Query;
import androidx.room.Update;


import com.example.pets.model.entities.Post;

import java.util.List;

@Dao
public interface PostDao {

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    long insert(Post post);

    @Update
    void update(Post post);

    @Query("SELECT * FROM posts ORDER BY postId DESC")
    List<Post> getAllPosts();

    @Query("SELECT * FROM posts WHERE islost = 1 ORDER BY postId DESC")
    List<Post> getAllPostsLost();

    @Query("SELECT * FROM posts WHERE islost = 0 ORDER BY postId DESC")
    List<Post> getAllPostsDongtai();
    //"SELECT * FROM user WHERE uname = :uname"
    @Query("SELECT * FROM posts WHERE postId = :postId")
    Post getPostByid(int postId);
}
